﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace table_json
{
    internal class FileUtil
    {

        public static String readFile(string path) { 
            return File.ReadAllText(path);
        }

        public static JToken readFileJson(string path)
        {
            String res =  File.ReadAllText(path);
            if (res == null||res.Trim().Equals(""))
            {
                res = "{\r\n  \"header\": {\r\n    \"name\": {\r\n      \"type\": \"str\",\r\n      \"desc\": \"名字\"\r\n    },\r\n  },\r\n  \"data\": [\r\n    {\r\n      \"name\": \"小张\"\r\n    }\r\n  ]\r\n}";
            }
         return   JToken.Parse(res);
        }
        public static void writeFile(string path,string data)
        {
            File.WriteAllText(path, data);
        }
    }
}
